package com.guizi.halftimesroom.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.guizi.halftimesroom.R;
import com.guizi.halftimesroom.bean.RecommandEventBean;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Alan on 2016/7/20.
 */
public class RecommandEventsView extends LinearLayout {
    private Context mContext;
    private LinearLayout ll_events;

    public RecommandEventsView(Context context) {
        this(context,null);
    }

    public RecommandEventsView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public RecommandEventsView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }

    private void initView(Context context) {
        this.mContext=context;
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_discover_recommand_events, this);
        ll_events = (LinearLayout) view.findViewById(R.id.ll_events);
    }
    public void setData(List<RecommandEventBean.DataBean> list){
        for (int i = 0; i <list.size(); i++) {
            ImageView imageView = new ImageView(mContext);
            LayoutParams params = new LayoutParams(200,170);
            params.setMargins(3,0,3,5);
            imageView.setLayoutParams(params);
            Picasso.with(mContext).load(list.get(i).getCover()).into(imageView);
            imageView.setScaleType(ImageView.ScaleType.FIT_XY);
            ll_events.addView(imageView);
        }
    }
}
